<?php

// 管理员登录
if (!function_exists('load_admin_login_routes')) {
    function load_admin_login_routes($api, $authApi)
    {
        $api && $api->post('ucenter/user/login', 'Ucenter\\UserController@login');
        $authApi && $authApi->group(
            [
                'prefix' => 'ucenter/user',
                'namespace' => 'Ucenter'
            ],
            function ($uApi) {
                $uApi->post('logout', 'UserController@logout');
                $uApi->get('info', 'UserController@info');
                $uApi->post('update-pwd', 'UserController@updatePwd');
            }
        );
    }
}

$api = app('Dingo\Api\Routing\Router');

$api->version(
    'v1',
    [
        'domain' => config('app.url'),
        'prefix' => 'admin',
        'namespace' => 'App\Http\Controllers\Admin',
        'middleware' => ['api.throttle'],
        'limit' => 100,
        'expires' => 1,
    ],
    function ($api) {
        load_admin_login_routes($api, null);
        $api->group(
            ['middleware' => ['auth.jwt:admin']],
            function ($authApi) {
                load_admin_login_routes(null, $authApi);
            }
        );
    }
);
